package cn.javazd.tcp;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;

public class TcpClient {

	public static void main(String[] args) {
		try {
			Socket socket = new Socket(InetAddress.getLocalHost(), 9090);
			OutputStream out = socket.getOutputStream();
			out.write("helle server!!!".getBytes());

			InputStream in = socket.getInputStream();
			byte[] buf = new byte[1024];
			int length = in.read(buf);
			System.out.println("client receive data: " + new String(buf, 0, length));
			socket.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
